<?php
/**
 * eg. <{pager_all pagesum=20}>
 */
function __f1($i, $j, $c) { for ($k = $i; $k <= $j; $k++) $a[] = $c == $k ? "<li class=\"pagebarCurrent\">$k</li>" : "<li><a href=\"?" . __f2($k) . "\">$k</a></li>"; return empty($a) ? '' :  implode(' ', $a); }
function __f2($p) { return preg_match(';(^|&)page=(\d+)($|&);i', $_SERVER["QUERY_STRING"]) ?  preg_replace(';(^|&)page=(\d+)($|&);i', '$1page=' . $p . '$3', $_SERVER["QUERY_STRING"]) : ($_SERVER["QUERY_STRING"] ? $_SERVER["QUERY_STRING"] . '&page=' . $p : 'page=' . $p); }
function smarty_function_pager_all($params, &$smarty)
{
    ;
    $pagesum = $params['pagesum'];
	if ($pagesum < 2) return '';
    $page = !empty($_GET['page']) ? (int) $_GET['page'] : 1;
    $navleft = 1;
    $navright = $pagesum;
    return '<div class="nav pagebar fix"><ul>'. (__f1($navleft, $navright, $page)) . '</ul></div>';
}
?>
